{__NOLAYOUT__}
<layout name="no_nav" />
<link rel="stylesheet" href="__STYLE__/DisShop/script/jquery-1.9.1.min.js">
<style type="text/css">
	body {
		position: relative;
		height: 100%;
		width: 100%;
		background: #eee url({$style.bg_image}) 0 0 no-repeat;
		background-size: cover;
		overflow: hidden;
		padding-bottom: 0;
	}
	.gh-gl {
		position: absolute;
		top: 50%;
		left: 50%;
		width: 80%;
		text-align: center;
		-webkit-transform: translate(-50%, -50%);
		-ms-transform: translate(-50%, -50%);
		transform: translate(-50%, -50%);
	}
	.gh-gl-item {
		display: block;
		margin-bottom: .2em;
		padding-top: .5em;
		padding-bottom: .5em;
		background-color: rgba(255, 255, 255, .8);
		text-decoration: underline;
	}
	.gh-tip {
		position: absolute;
		top: 0;
		left: 0;
	}
	.pr-copyright {
		position: absolute;
		bottom: 0;
		width: 100%;
	}
	.ellipsis{
		padding-top: 1px;
	}
</style>

<header style="position:relative; height: 1px;"></header>
<header class="gh-tip flex-row">
	<div class="row-item">
		<eq name="user.subscribe" value="0">
			<notempty name="fromUser">
				<notempty name="fromUser.face">
					<div class="gh-tip-face fl">
						<img class="w100" src="{$fromUser.face}" alt="" style="width:100px">
					</div>
				</notempty>
				<p class="ellipsis">来自 {$fromUser.nickname} 的推荐</p>
				<p class="ellipsis">关注我们，获取更多优惠</p>
			</notempty>
			<else/>
			<notempty name="user">
				<notempty name="user.face">
					<div class="gh-tip-face fl">
						<img class="w100" src="{$user.face}" alt="">
					</div>
				</notempty>
				<p class="ellipsis">{$user.nickname}，感谢您的关注</p>
				<p class="ellipsis">分享给朋友，获取分享积分</p>
			</notempty>
		</eq>
	</div>

	<if condition="!$user['subscribe']">
		<a href="{$config.subscribe_url}" class="btn btn-theme">关注我们</a>
		<else/>
		<a href="{:url(null, 'DisShop', 'my', 'sid='.$sid)}" class="btn btn-theme" style="font-size: 11px;">个人中心</a>
		<span id="baidu_geo"></span>
	</if>
</header>

<main class="gh-gl">
	<volist name="goodsLists" id="vo">
		<a class="gh-gl-item" href="{$vo.url}">{$vo.name}</a>
	</volist>
</main>
<script>
function getLocation(){
	if (navigator.geolocation){
		navigator.geolocation.getCurrentPosition(showPosition,showError);
	}else{
		alert("浏览器不支持地理定位。");
	}
}

function showPosition(position){
	$("#latlon").html("纬度:"+position.coords.latitude +'，经度:'+ position.coords.longitude);
	var latlon = position.coords.latitude+','+position.coords.longitude;
	
	//baidu
	var url = "http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location="+latlon+"&output=json&pois=0";
	$.ajax({ 
		type: "GET", 
		dataType: "jsonp", 
		url: url,
		beforeSend: function(){
			$("#baidu_geo").html('正在定位...');
		},
		success: function (json) { 
			if(json.status==0){
			var asfd = json.result.formatted_address;
			
			var a = asfd.indexOf('市');
		   
			
			var asfds = asfd.substring(0,a+1,'utf-8');
			
				$("#baidu_geo").html(asfds);

			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) { 
			$("#baidu_geo").html(latlon+"地址位置获取失败"); 
		}
	});
	
	//google
	var url = 'http://maps.google.cn/maps/api/geocode/json?latlng='+latlon+'&language=CN';
	$.ajax({ 
		type: "GET",
		url: url, 
		beforeSend: function(){
			$("#google_geo").html('正在定位...');
		},
		success: function (json) { 
			if(json.status=='OK'){
				var results = json.results;
				$.each(results,function(index,array){
					if(index==0){
					$("#google_geo").html(array['formatted_address']);
					}
				});
			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) { 
			$("#google_geo").html(latlon+"地址位置获取失败"); 
		} 
	});
}

function showError(error){
	switch(error.code) {
		case error.PERMISSION_DENIED:
			alert("定位失败,用户拒绝请求地理定位");
			break;
		case error.POSITION_UNAVAILABLE:
			alert("定位失败,位置信息是不可用");
			break;
		case error.TIMEOUT:
			alert("定位失败,请求获取用户位置超时");
			break;
		case error.UNKNOWN_ERROR:
			alert("定位失败,定位系统失效");
			break;
    }
}

getLocation();
</script>